<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>8-ajax表单提交获取属性值</title>
		<script type="text/javascript" src="js/jquery2.1.4.min.js"></script>
	</head>
	<body>
		
		<form action="#" method="post">
			标题：<input type="text" name="title" id="title"><br>
			摘要：<input type="text" name="descr" id="descr"><br>
			<span uid="20" style="display:none;" id="author">作者：</span><br>
			<input type="submit" value="提交" id="add">
		</form>
		<script type="text/javascript">
			//需求：表单提交需要3个参数 title,descr,uid
			$(function(){
				
				$('#add').click(function(){
					//alert(1);
					//获取值
					var title = $('#title').val();
					var descr = $('#descr').val();
					var uid = $('#author').attr('uid');
					
					//1.数据校验
					
					//2.发送ajax
					$.ajax({
						url:'',
						type:'POST',
						data:{
							title:title,
							descr:descr,
							uid:uid
						},
						dataType:'json',
						success:function(res){
							
						}
					});
					return false;
				});
				
			});
		</script>
	</body>
</html>
